﻿<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>v-for与计算属性</title>
	</head>
	<body>
		<div id="app">
		  <h1>已完成的工作计划</h1>
			<ul>
				<li v-for="plan in completedPlans">
					{{plan.content}}
				</li>
			</ul>
			<h1>未完成的工作计划</h1>
			<ul>
				<li v-for="plan in incompletePlans">
					{{plan.content}}
				</li>
			</ul>
		</div>
	
		<script src="https://unpkg.com/vue@next"></script>
		<script>
			const vm = Vue.createApp({
                data() {
                    return {
                        plans: [
                        	{content: '写《Java无难事》', isComplete: false},
                        	{content: '买菜', isComplete: true},
                        	{content: '写PPT', isComplete: false},
                        	{content: '做饭', isComplete: true},
                        	{content: '打羽毛球', isComplete: false}
                        ]
                    }
                },
                computed: {
                    completedPlans() {
                        return this.plans.filter(plan => plan.isComplete);
                    },
                    incompletePlans(){
                        return this.plans.filter(plan => !plan.isComplete);
                    }
                }
			}).mount('#app');
		</script>
	</body>
</html>